package com.example.rabbitmq.example.rabbitmq.work;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class WorkQueueProducer {

    public static void main(String[] args) throws Exception{
        ConnectionFactory factory = new  ConnectionFactory();
        factory.setUri("amqp://admin:admin@192.168.1.3:5672/%2f");
        final Connection connection = factory.newConnection();
        final Channel channel = connection.createChannel();

        channel.queueDeclare("queue1", true, false,false, null);
        channel.exchangeDeclare("exchange1", BuiltinExchangeType.DIRECT, true,false, null);
        channel.queueBind("queue1", "exchange1", "key.wq");

        for (int i = 0; i < 20; i++) {
            channel.basicPublish("exchange1","key.wq", null, ("work_queue"+i).getBytes());
        }
        channel.close();
        connection.close();
    }
}
